module cl {
	export class MoveAction extends ActionPerformer {
		constructor() {
			super();
			this.type = 2;
			this.paramKeys = "[]";
			this.paramVals = "[]";
		}

		public accept() : void {
			// let vals = JSON.parse(this.paramVals);
			// let keys = JSON.parse(this.paramKeys);
			let troop = Campaign.troop[this.troopid];

			// 看见路径周围
			ActionUtil.setAction(new SeeAction(troop.force), this.troopid, this.move_remain, this.tid).accept();

			// 数据
			troop.orientation = Map.tileEngine.headingIndex(Map.tileEngine.twoTidHeading(troop.tid, this.tid));
			Campaign.troop_map[troop.tid] = -1;
			Campaign.troop_map[this.tid] = this.troopid;
			troop.tile = Map.tileEngine.tid2tile(this.tid);
			troop.refreshLocation();
			troop.move_remain = this.move_remain;
		}

		public acceptOnce() : void { this.accept(); }

		public duration() : number {
			return 300;
		}

		public play(map : CampaignPage) : void {
			// 看见路径周围
			ActionUtil.setAction(new SeeAction(Campaign.troop_force[this.troopid]), this.troopid, this.move_remain, this.tid).play(map);

			// 动作动画
			let troopGroup = map.groupTroop.getChildByName(String(this.troopid)) as eui.Group;
			let troopImage = troopGroup.getChildAt(1);
			let coord = Map.tileEngine.tid2coord(this.tid);
			let orient = Map.tileEngine.headingIndex(Map.tileEngine.twoCoordHeading(new Coord(troopGroup.x, troopGroup.y), coord));
			Util.setOrientation(troopImage, orient);
			egret.Tween.get(troopGroup).to(coord, this.duration() - 50);
			MoveRemainEffect.play(troopGroup, this.move_remain);
		}
	}
}